import { asyncRoutes, constantRoutes } from '@/router/index.js'
const state = {
  routes: constantRoutes // 配置 路由 信息表
}
// 在 mutation中 修改路由信息 这里就可以 添加 过滤后的 路由 信息
const mutations = {
  setRoutes(state, newRoutes) {
    state.routes = [...constantRoutes, ...newRoutes]
  }
}
// 需要 发出 异步 修改 数据的请求
const actions = {
  // 筛选菜单
  filterRoutes(context, menus) {
    // const filterRoutes = asyncRoutes.filter(t => menus.includes(t.name))
    const filterRoutes = asyncRoutes
    context.commit('setRoutes', filterRoutes)
    return filterRoutes
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
